package com.onegroup.controller;

import com.onegroup.pojo.Expert;
import com.onegroup.service.ExpertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 罗宇豪
 * @Date 2022/09/08 16:01
 * @Description
 * @History
 **/
@RestController
public class ExpertController {

    @Autowired
    private ExpertService expertService;

    //显示所有专家列表
    @GetMapping("/showAllExperts")
    public List<Expert> showAllExperts() {
       return this.expertService.queryAllExperts();
    }

    //依据条件(id,name,username)模糊查找专家
    @GetMapping("/showExpertByCondition")
    public List<Expert> showExpertByCondition(Expert expert) {
        System.out.println(this.expertService.queryExpertByCondition(expert));
        return this.expertService.queryExpertByCondition(expert);
    }

    //删除指定id的专家
    @PostMapping("/removeExpertById")
    public void removeExpertById(Integer[] expIds) {
        this.expertService.removeExpertByIds(expIds);
    }

    //添加专家
    @PostMapping("/addExpert")
    public void addExpert(Expert expert) {
        this.expertService.addExpert(expert);
    }

    //修改专家信息
    @PostMapping("/modifyExpert")
    public void modifyExpert(Expert expert) {
        this.expertService.modifyExpert(expert);
    }

}
